package com.wanmait.translate.administration.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.translate.administration.mapper.AdministrationTicketMapper;
import com.wanmait.translate.administration.mapper.CityMapper;
import com.wanmait.translate.administration.mapper.ProvinceMapper;
import com.wanmait.translate.administration.service.AdministrationTicketService;
import com.wanmait.translate.pojo.AdministrationTicket;
import com.wanmait.translate.pojo.City;
import com.wanmait.translate.pojo.Province;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class TicketServiceImpl implements AdministrationTicketService {
    @Resource
    private AdministrationTicketMapper administrationTicketMapper;
    @Resource
    private ProvinceMapper provinceMapper;
    @Resource
    private CityMapper cityMapper;
    @Override
    public void insert(AdministrationTicket object) {
        administrationTicketMapper.insertSelective(object);
    }

    @Override
    public void update(AdministrationTicket object) {
        administrationTicketMapper.updateByPrimaryKeySelective(object);
    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public AdministrationTicket selectOne(Integer id) {
        return administrationTicketMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<AdministrationTicket> selectList() {
        return administrationTicketMapper.listAll();
    }

    @Override
    public List<AdministrationTicket> selectList(AdministrationTicket object) {
        return null;
    }

    @Override
    public PageInfo<AdministrationTicket> listAllByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<AdministrationTicket> ticketPageInfo = administrationTicketMapper.listAll();
        return new PageInfo<>(ticketPageInfo,9);
    }

    @Override
    public List<Province> ListAllProvince() {
        return provinceMapper.ListAll();
    }

    @Override
    public List<City> ListCitiesById(Integer id) {
        return cityMapper.listCitysById(id);
    }

    @Override
    public PageInfo<AdministrationTicket> ListAllByName(Integer pageNum, Integer pageSize, String name) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(administrationTicketMapper.listAllByName(name),9);
    }

    @Override
    public PageInfo<AdministrationTicket> ListAllByBooking(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(administrationTicketMapper.listAllByBooking(),9);
    }

    @Override
    public PageInfo<AdministrationTicket> ListAllByNotBooking(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(administrationTicketMapper.listAllByNotBooking(),9);
    }


}
